﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MisClient
{
    public partial class FrmCustomer : Form
    {
        private string opState;

        private IBLL.ICustomer customerBLL = MisCLL.DAOFactory.CreateInstance().GetRemoteCustomer();

        public FrmCustomer()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            this.txtCus_ID.ReadOnly = false;
            this.txtMM.ReadOnly = false;
            this.txtCType.ReadOnly = false;
            this.txtCustomer.ReadOnly = false;
            this.txtBei1.ReadOnly = false;
            this.chkF1.Enabled = true;
            this.dtpDateS.Enabled = true;
            this.dtpDateE.Enabled = true;
            this.txtFaiTh.ReadOnly = false;
            this.txtFaiThJe.ReadOnly = false;
            this.txtDebt.ReadOnly = false;
            this.txtSex.ReadOnly = false;
            this.txtMenId.ReadOnly = false;
            this.txtProf.ReadOnly = false;
            this.dtpBirthday.Enabled = true;
            this.txtAddr.ReadOnly = false;
            this.txtPost.ReadOnly = false;
            this.txtTele.ReadOnly = false;
            this.txtAllName.ReadOnly = false;
            this.txtBank.ReadOnly = false;
            this.txtBankNo.ReadOnly = false;
            this.txtTaxNo.ReadOnly = false;
            this.txtLinker.ReadOnly = false;
            this.txtF2.ReadOnly = false;
            this.txtBei.ReadOnly = false;
            this.txtSumJeBuy1.ReadOnly = false;
            this.txtSumJeDed1.ReadOnly = false;
            this.txtSumJeBuy.ReadOnly = false;
            this.txtSumJeDed.ReadOnly = false;

            this.btnAdd.Enabled = false;
            this.btnDel.Enabled = false;
            this.btnMod.Enabled = false;
            this.btnSek.Enabled = false;
            this.btnPrint.Enabled = false;
            this.btnRef.Enabled = false;
            this.btnQuit.Enabled = false;
            this.btnOk.Enabled = true;
            this.btnCan.Enabled = true;

            this.txtCus_ID.Text = customerBLL.FindLastId().ToString();
            this.txtMM.Text = "888888";
            this.txtCType.Text = "A";
            this.txtCustomer.Clear();
            this.txtBei1.Text = "其它";
            this.chkF1.Checked = true;
            this.dtpDateS.Value = DateTime.Now;
            this.dtpDateE.Value = DateTime.Now;
            this.txtFaiTh.Text = "1";
            this.txtFaiThJe.Text = "0";
            this.txtDebt.Text = "0";
            this.txtSex.Text = "M";
            this.txtMenId.Clear();
            this.txtProf.Text = "99";
            this.dtpBirthday.Value = DateTime.Now;
            this.txtAddr.Clear();
            this.txtPost.Clear();
            this.txtTele.Clear();
            this.txtAllName.Clear();
            this.txtBank.Clear();
            this.txtBankNo.Clear();
            this.txtTaxNo.Clear();
            this.txtLinker.Clear();
            this.txtF2.Clear();
            this.txtBei.Clear();
            this.txtSumJeBuy1.Clear();
            this.txtSumJeDed1.Clear();
            this.txtSumJeBuy.Clear();
            this.txtSumJeDed.Clear();
            this.txtCus_ID.Focus();

            this.opState = "添加";
        }

        private void btnDel_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtCus_ID.Text))
            {
                MessageBox.Show("不可删除！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (this.chkF1.Checked)
            {
                MessageBox.Show("可用机器，不可删除！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!string.IsNullOrEmpty(this.txtDebt.Text) && decimal.Parse(this.txtDebt.Text) > 0)
            {
                MessageBox.Show("有结存金额，不可删除！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (MessageBox.Show("请确认删除[y/n]？", "提问窗", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                int ok = customerBLL.Delete(this.txtCus_ID.Text.Trim());
                if (ok == -1)
                {
                    MessageBox.Show("操作失败！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show("本条记录已成功删除！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtCus_ID.Clear();
                    this.txtMM.Text = "888888";
                    this.txtCType.Text = "A";
                    this.txtCustomer.Clear();
                    this.txtBei1.Text = "其它";
                    this.chkF1.Checked = true;
                    this.dtpDateS.Value = DateTime.Now;
                    this.dtpDateE.Value = DateTime.Now;
                    this.txtFaiTh.Text = "1";
                    this.txtFaiThJe.Text = "0";
                    this.txtDebt.Text = "0";
                    this.txtSex.Text = "M";
                    this.txtMenId.Clear();
                    this.txtProf.Text = "99";
                    this.dtpBirthday.Value = DateTime.Now;
                    this.txtAddr.Clear();
                    this.txtPost.Clear();
                    this.txtTele.Clear();
                    this.txtAllName.Clear();
                    this.txtBank.Clear();
                    this.txtBankNo.Clear();
                    this.txtTaxNo.Clear();
                    this.txtLinker.Clear();
                    this.txtF2.Clear();
                    this.txtBei.Clear();
                    this.txtSumJeBuy1.Clear();
                    this.txtSumJeDed1.Clear();
                    this.txtSumJeBuy.Clear();
                    this.txtSumJeDed.Clear();
                    this.btnDel.Enabled = false;
                    this.btnMod.Enabled = false;
                }
            }
        }

        private void btnMod_Click(object sender, EventArgs e)
        {

            this.txtCus_ID.ReadOnly = true;
            this.txtMM.ReadOnly = true;
            this.txtCType.ReadOnly = false;
            this.txtCustomer.ReadOnly = false;
            this.txtBei1.ReadOnly = false;
            this.chkF1.Enabled = true;
            this.dtpDateS.Enabled = true;
            this.dtpDateE.Enabled = true;
            this.txtFaiTh.ReadOnly = false;
            this.txtFaiThJe.ReadOnly = false;
            this.txtDebt.ReadOnly = true;
            this.txtSex.ReadOnly = false;
            this.txtMenId.ReadOnly = false;
            this.txtProf.ReadOnly = false;
            this.dtpBirthday.Enabled = true;
            this.txtAddr.ReadOnly = false;
            this.txtPost.ReadOnly = false;
            this.txtTele.ReadOnly = false;
            this.txtAllName.ReadOnly = false;
            this.txtBank.ReadOnly = false;
            this.txtBankNo.ReadOnly = false;
            this.txtTaxNo.ReadOnly = false;
            this.txtLinker.ReadOnly = false;
            this.txtF2.ReadOnly = false;
            this.txtBei.ReadOnly = false;
            this.txtSumJeBuy1.ReadOnly = true;
            this.txtSumJeDed1.ReadOnly = true;
            this.txtSumJeBuy.ReadOnly = true;
            this.txtSumJeDed.ReadOnly = true;


            this.btnAdd.Enabled = false;
            this.btnDel.Enabled = false;
            this.btnMod.Enabled = false;
            this.btnSek.Enabled = false;
            this.btnPrint.Enabled = false;
            this.btnRef.Enabled = false;
            this.btnQuit.Enabled = false;
            this.btnOk.Enabled = true;
            this.btnCan.Enabled = true;
            this.opState = "修改";
        }

        private void btnSek_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;
            btn.FlatAppearance.BorderSize = 0;
            Point point = new Point(btn.Left + this.Left + 5, btn.Top + this.Top + 40);
            contextMenuAssign.Show(point);
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.opState))
            {
                bool isOk = false;
                if (this.opState == "添加")
                {
                    isOk = Add();
                }
                else if (this.opState == "修改")
                {
                    isOk = Mod();
                }

                if (isOk)
                {
                    this.txtCus_ID.ReadOnly = true;
                    this.txtMM.ReadOnly = true;
                    this.txtCType.ReadOnly = true;
                    this.txtCustomer.ReadOnly = true;
                    this.txtBei1.ReadOnly = true;
                    this.chkF1.Enabled = false;
                    this.dtpDateS.Enabled = false;
                    this.dtpDateE.Enabled = false;
                    this.txtFaiTh.ReadOnly = true;
                    this.txtFaiThJe.ReadOnly = true;
                    this.txtDebt.ReadOnly = true;
                    this.txtSex.ReadOnly = true;
                    this.txtMenId.ReadOnly = true;
                    this.txtProf.ReadOnly = true;
                    this.dtpBirthday.Enabled = false;
                    this.txtAddr.ReadOnly = true;
                    this.txtPost.ReadOnly = true;
                    this.txtTele.ReadOnly = true;
                    this.txtAllName.ReadOnly = true;
                    this.txtBank.ReadOnly = true;
                    this.txtBankNo.ReadOnly = true;
                    this.txtTaxNo.ReadOnly = true;
                    this.txtLinker.ReadOnly = true;
                    this.txtF2.ReadOnly = true;
                    this.txtBei.ReadOnly = true;
                    this.txtSumJeBuy1.ReadOnly = true;
                    this.txtSumJeDed1.ReadOnly = true;
                    this.txtSumJeBuy.ReadOnly = true;
                    this.txtSumJeDed.ReadOnly = true;
                    this.btnAdd.Enabled = true;
                    this.btnDel.Enabled = true;
                    this.btnMod.Enabled = true;
                    this.btnSek.Enabled = true;
                    this.btnPrint.Enabled = true;
                    this.btnRef.Enabled = true;
                    this.btnQuit.Enabled = true;
                    this.btnOk.Enabled = false;
                    this.btnCan.Enabled = false;
                    this.btnAdd.Focus();
                }
            }
        }

        //添加客户档案代码
        protected bool Add()
        {
            if (this.txtCustomer.Text.Trim().Length == 0)
            {
                MessageBox.Show("名称不能为空！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtCustomer.Focus();
                return false;
            }
            if (this.txtCus_ID.Text.Trim().Length == 0)
            {
                MessageBox.Show("编码长度不符,应为4！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtCus_ID.Focus();
                return false;
            }

            MisModel.Customer obj = new MisModel.Customer();

            obj.CusID = this.txtCus_ID.Text.Trim();
            obj.MM = this.txtMM.Text.Trim();
            obj.CType = this.txtCType.Text.Trim();
            obj.Customer_ = this.txtCustomer.Text.Trim();
            if (this.chkF1.Checked)
                obj.F1 = "1";
            else
                obj.F1 = "0";
            obj.DateS = this.dtpDateS.Value;
            obj.DateE = this.dtpDateE.Value;
            obj.FaiTh = this.txtFaiTh.Text.Trim();
            if (!string.IsNullOrEmpty(this.txtFaiThJe.Text))
                obj.FaiThJe = decimal.Parse(this.txtFaiThJe.Text.Trim());
            obj.Debt = this.txtDebt.Text.Trim();
            obj.Sex = this.txtSex.Text.Trim();
            obj.MenID = this.txtMenId.Text.Trim();
            obj.Prof = this.txtProf.Text.Trim();
            obj.Birthday = this.dtpBirthday.Value;
            obj.Addr = this.txtAddr.Text.Trim();
            obj.Post = this.txtPost.Text.Trim();
            obj.Tele = this.txtTele.Text.Trim();
            obj.AllName = this.txtAllName.Text.Trim();
            obj.Bank = this.txtBank.Text.Trim();
            obj.BankNo = this.txtBankNo.Text.Trim();
            obj.TaxNo = this.txtTaxNo.Text.Trim();
            obj.Liker = this.txtLinker.Text.Trim();
            obj.F2 = this.txtF2.Text.Trim();
            obj.Bei = this.txtBei.Text.Trim();
            if (!string.IsNullOrEmpty(this.txtSumJeBuy.Text))
                obj.SumJeBuy = decimal.Parse(this.txtSumJeBuy.Text.Trim());
            if (!string.IsNullOrEmpty(this.txtSumJeDed.Text))
                obj.SumJeDed = decimal.Parse(this.txtSumJeDed.Text.Trim());
            obj.DateL = DateTime.Now;
            int ok = customerBLL.Add(obj);
            if (ok == -1)
            {
                MessageBox.Show("操作失败！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }
            else
            {
                MessageBox.Show("本条记录已成功添加！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return true;
        }

        //保存客户档案代码
        protected bool Mod()
        {
            if (this.txtCustomer.Text.Trim().Length == 0)
            {
                MessageBox.Show("名称不能为空！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtCustomer.Focus();
                return false;
            }
            if (this.txtCus_ID.Text.Trim().Length == 0)
            {
                MessageBox.Show("编码长度不符,应为4！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtCus_ID.Focus();
                return false;
            }
            MisModel.Customer obj = new MisModel.Customer();

            obj.CusID = this.txtCus_ID.Text.Trim();
            obj.MM = this.txtMM.Text.Trim();
            obj.CType = this.txtCType.Text.Trim();
            obj.Customer_ = this.txtCustomer.Text.Trim();
            if (this.chkF1.Checked)
                obj.F1 = "1";
            else
                obj.F1 = "0";
            obj.DateS = this.dtpDateS.Value;
            obj.DateE = this.dtpDateE.Value;
            obj.FaiTh = this.txtFaiTh.Text.Trim();
            if (!string.IsNullOrEmpty(this.txtFaiThJe.Text))
                obj.FaiThJe = decimal.Parse(this.txtFaiThJe.Text.Trim());
            obj.Debt = this.txtDebt.Text.Trim();
            obj.Sex = this.txtSex.Text.Trim();
            obj.MenID = this.txtMenId.Text.Trim();
            obj.Prof = this.txtProf.Text.Trim();
            obj.Birthday = this.dtpBirthday.Value;
            obj.Addr = this.txtAddr.Text.Trim();
            obj.Post = this.txtPost.Text.Trim();
            obj.Tele = this.txtTele.Text.Trim();
            obj.AllName = this.txtAllName.Text.Trim();
            obj.Bank = this.txtBank.Text.Trim();
            obj.BankNo = this.txtBankNo.Text.Trim();
            obj.TaxNo = this.txtTaxNo.Text.Trim();
            obj.Liker = this.txtLinker.Text.Trim();
            obj.F2 = this.txtF2.Text.Trim();
            obj.Bei = this.txtBei.Text.Trim();
            if (!string.IsNullOrEmpty(this.txtSumJeBuy.Text))
                obj.SumJeBuy = decimal.Parse(this.txtSumJeBuy.Text.Trim());
            if (!string.IsNullOrEmpty(this.txtSumJeDed.Text))
                obj.SumJeDed = decimal.Parse(this.txtSumJeDed.Text.Trim());
            obj.DateL = DateTime.Now;
            int ok = customerBLL.Update(obj);
            if (ok == -1)
            {
                MessageBox.Show("操作失败！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }
            else
            {
                MessageBox.Show("本条记录已成功修改！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return true;
        }

        private void btnCan_Click(object sender, EventArgs e)
        {

            this.txtCus_ID.ReadOnly = true;
            this.txtMM.ReadOnly = true;
            this.txtCType.ReadOnly = true;
            this.txtCustomer.ReadOnly = true;
            this.txtBei1.ReadOnly = true;
            this.chkF1.Enabled = false;
            this.dtpDateS.Enabled = false;
            this.dtpDateE.Enabled = false;
            this.txtFaiTh.ReadOnly = true;
            this.txtFaiThJe.ReadOnly = true;
            this.txtDebt.ReadOnly = true;
            this.txtSex.ReadOnly = true;
            this.txtMenId.ReadOnly = true;
            this.txtProf.ReadOnly = true;
            this.dtpBirthday.Enabled = false;
            this.txtAddr.ReadOnly = true;
            this.txtPost.ReadOnly = true;
            this.txtTele.ReadOnly = true;
            this.txtAllName.ReadOnly = true;
            this.txtBank.ReadOnly = true;
            this.txtBankNo.ReadOnly = true;
            this.txtTaxNo.ReadOnly = true;
            this.txtLinker.ReadOnly = true;
            this.txtF2.ReadOnly = true;
            this.txtBei.ReadOnly = true;
            this.txtSumJeBuy1.ReadOnly = true;
            this.txtSumJeDed1.ReadOnly = true;
            this.txtSumJeBuy.ReadOnly = true;
            this.txtSumJeDed.ReadOnly = true;

            this.btnAdd.Enabled = true;
            this.btnDel.Enabled = true;
            this.btnMod.Enabled = true;
            this.btnSek.Enabled = true;
            this.btnPrint.Enabled = true;
            this.btnRef.Enabled = true;
            this.btnQuit.Enabled = true;
            this.btnOk.Enabled = false;
            this.btnCan.Enabled = false;
            this.btnAdd.Focus();

            DataRowView view = this.lbxList.SelectedItem as DataRowView;
            if (view != null)
            {
                this.txtCus_ID.Text = view.Row["CUS_ID"].ToString().Trim();
                this.txtMM.Text = view.Row["MM"].ToString().Trim();
                this.txtCType.Text = view.Row["CTYPE"].ToString().Trim();
                this.txtCustomer.Text = view.Row["CUSTOMER"].ToString().Trim();
                if (view.Row["F1"].ToString() == "1")
                {
                    this.chkF1.Checked = true;
                }
                else
                {
                    this.chkF1.Checked = false;
                }
                this.dtpDateS.Value = Convert.ToDateTime(view.Row["DATE_s"]);
                this.dtpDateE.Value = Convert.ToDateTime(view.Row["DATE_e"]);
                this.txtFaiTh.Text = view.Row["FAITH"].ToString().Trim();
                if (view.Row["FAITHJE"] != null)
                    this.txtFaiThJe.Text = String.Format("{0:N2}", view.Row["FAITHJE"].ToString());
                if (view.Row["DEBT"] != null)
                    this.txtDebt.Text = String.Format("{0:N2}", view.Row["DEBT"].ToString());
                this.txtSex.Text = view.Row["SEX"].ToString().Trim();
                this.txtMenId.Text = view.Row["MENID"].ToString().Trim();
                this.txtProf.Text = view.Row["PROF"].ToString().Trim();
                this.dtpBirthday.Value = Convert.ToDateTime(view.Row["BIRTHDAY"]);
                this.txtAddr.Text = view.Row["ADDR"].ToString().Trim();
                this.txtPost.Text = view.Row["POST"].ToString().Trim();
                this.txtTele.Text = view.Row["TELE"].ToString().Trim();
                this.txtAllName.Text = view.Row["ALLNAME"].ToString().Trim();
                this.txtBank.Text = view.Row["BANK"].ToString().Trim();
                this.txtBankNo.Text = view.Row["BANKNO"].ToString().Trim();
                this.txtTaxNo.Text = view.Row["TAXNO"].ToString().Trim();
                this.txtLinker.Text = view.Row["LINKER"].ToString().Trim();
                this.txtF2.Text = view.Row["F2"].ToString().Trim();
                this.txtBei.Text = view.Row["BEI"].ToString().Trim();
                if (view.Row["SUMJEBUY"] != null)
                    this.txtSumJeBuy1.Text = String.Format("{0:N2}", view.Row["SUMJEBUY"].ToString());
                if (view.Row["SUMJEDED"] != null)
                    this.txtSumJeDed1.Text = String.Format("{0:N2}", view.Row["SUMJEDED"].ToString());
                this.txtSumJeBuy.Text = this.txtSumJeBuy1.Text;
                this.txtSumJeDed.Text = this.txtSumJeDed1.Text;
            }
        }

        private void lbxList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            DataRowView view = this.lbxList.SelectedItem as DataRowView;
            this.txtCus_ID.Text = view.Row["CUS_ID"].ToString().Trim();
            this.txtMM.Text = view.Row["MM"].ToString().Trim();
            this.txtCType.Text = view.Row["CTYPE"].ToString().Trim();
            this.txtCustomer.Text = view.Row["CUSTOMER"].ToString().Trim();
            if (view.Row["F1"].ToString() == "1")
            {
                this.chkF1.Checked = true;
            }
            else
            {
                this.chkF1.Checked = false;
            }
            this.dtpDateS.Value = Convert.ToDateTime(view.Row["DATE_s"]);
            this.dtpDateE.Value = Convert.ToDateTime(view.Row["DATE_e"]);
            this.txtFaiTh.Text = view.Row["FAITH"].ToString().Trim();
            if (view.Row["FAITHJE"] != null)
                this.txtFaiThJe.Text = String.Format("{0:N2}", view.Row["FAITHJE"].ToString());
            if (view.Row["DEBT"] != null)
                this.txtDebt.Text = String.Format("{0:N2}", view.Row["DEBT"].ToString());
            this.txtSex.Text = view.Row["SEX"].ToString().Trim();
            this.txtMenId.Text = view.Row["MENID"].ToString().Trim();
            this.txtProf.Text = view.Row["PROF"].ToString().Trim();
            this.dtpBirthday.Value = Convert.ToDateTime(view.Row["BIRTHDAY"]);
            this.txtAddr.Text = view.Row["ADDR"].ToString().Trim();
            this.txtPost.Text = view.Row["POST"].ToString().Trim();
            this.txtTele.Text = view.Row["TELE"].ToString().Trim();
            this.txtAllName.Text = view.Row["ALLNAME"].ToString().Trim();
            this.txtBank.Text = view.Row["BANK"].ToString().Trim();
            this.txtBankNo.Text = view.Row["BANKNO"].ToString().Trim();
            this.txtTaxNo.Text = view.Row["TAXNO"].ToString().Trim();
            this.txtLinker.Text = view.Row["LINKER"].ToString().Trim();
            this.txtF2.Text = view.Row["F2"].ToString().Trim();
            this.txtBei.Text = view.Row["BEI"].ToString().Trim();
            if (view.Row["SUMJEBUY"] != null)
                this.txtSumJeBuy1.Text = String.Format("{0:N2}", view.Row["SUMJEBUY"].ToString());
            if (view.Row["SUMJEDED"] != null)
                this.txtSumJeDed1.Text = String.Format("{0:N2}", view.Row["SUMJEDED"].ToString());
            this.txtSumJeBuy.Text = this.txtSumJeBuy1.Text;
            this.txtSumJeDed.Text = this.txtSumJeDed1.Text;
            this.lbxList.Hide();
            this.btnDel.Enabled = true;
            this.btnMod.Enabled = true;
        }

        private void ChoiseListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.lbxList.DisplayMember = "ItemShow";
            this.lbxList.DataSource = customerBLL.GetAll();
            this.lbxList.Show();
        }

        private void ByCodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] value = CusInputBox.Input("请输入查询条件：", "顾客编号", "顾客简称", "");
            if (value != null && value.Length >= 2)
            {
                if (!string.IsNullOrEmpty(value[0]))
                {
                    MisModel.Customer model = customerBLL.GetById(value[0]);
                    if (model != null)
                    {
                        this.txtCus_ID.Text = model.CusID;
                        this.txtMM.Text = model.MM;
                        this.txtCType.Text = model.CType;
                        this.txtCustomer.Text = model.Customer_;
                        if (model.F1 == "1")
                        {
                            this.chkF1.Checked = true;
                        }
                        else
                        {
                            this.chkF1.Checked = false;
                        }
                        this.dtpDateS.Value = model.DateS;
                        this.dtpDateE.Value = model.DateE;
                        this.txtFaiTh.Text = model.FaiTh;
                        this.txtFaiThJe.Text = String.Format("{0:N2}", model.FaiThJe.ToString());
                        this.txtDebt.Text = String.Format("{0:N2}", model.Debt.ToString());
                        this.txtSex.Text = model.Sex;
                        this.txtMenId.Text = model.MenID;
                        this.txtProf.Text = model.Prof;
                        this.dtpBirthday.Value = model.Birthday;
                        this.txtAddr.Text = model.Addr;
                        this.txtPost.Text = model.Post;
                        this.txtTele.Text = model.Tele;
                        this.txtAllName.Text = model.AllName;
                        this.txtBank.Text = model.Bank;
                        this.txtBankNo.Text = model.BankNo;
                        this.txtTaxNo.Text = model.TaxNo;
                        this.txtLinker.Text = model.Liker;
                        this.txtF2.Text = model.F2;
                        this.txtBei.Text = model.Bei;
                        this.txtSumJeBuy1.Text = String.Format("{0:N2}", model.SumJeBuy.ToString());
                        this.txtSumJeDed1.Text = String.Format("{0:N2}", model.SumJeDed.ToString());
                        this.txtSumJeBuy.Text = this.txtSumJeBuy1.Text;
                        this.txtSumJeDed.Text = this.txtSumJeDed1.Text;
                    }
                }
                else if (!string.IsNullOrEmpty(value[1]))
                {
                    DataTable dt =  customerBLL.GetByName(value[1]);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        this.lbxList.DisplayMember = "ItemShow";
                        this.lbxList.DataSource = dt;
                        this.lbxList.Show();
                    }
                    else
                    {
                        MessageBox.Show(string.Format("没有查询到（{0}）", value[1]), "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
